package org.tobaccomain.utils;

import dingsung.com.cn.Card;
import dingsung.com.cn.NetCardReader;
import lombok.extern.slf4j.Slf4j;

import java.util.List;

@Slf4j
public class RfidUtils {
    private RfidUtils() {
    }
    public static void search(List<Long> rfidList) {
        //初始化网络读卡器
        NetCardReader.init();
        //添加网络读卡器：环境中有几个就需要添加几个
        NetCardReader.newReader("192.168.10.196");
        NetCardReader.newReader("192.168.10.197");
        NetCardReader.newReader("192.168.10.198");
        NetCardReader.newReader("192.168.10.199");
        //添加之后需要休眠一小段时间
        try {
            Thread.sleep(500);
        } catch (InterruptedException e) {
            throw new RuntimeException(e);
        }
        //通过rfid查询
        for (int i = 0; i < rfidList.size(); i++) {
            try {
                Thread.sleep(2000);
                NetCardReader.callCard(rfidList.get(i), 0, 5);//0不响，1响
                log.info("查找到rfid号为:{},{}",i,rfidList.get(i));
                Thread.sleep(2000);

            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }

}
